﻿<UserControl x:Class="DoubanFM.PopupableColorPicker"
			 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
			 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
			 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
			 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:local="clr-namespace:DoubanFM"
			 mc:Ignorable="d" 
			 x:Name="UserControl"
			 d:DesignHeight="300" d:DesignWidth="300">
	<Grid>
		<Button x:Name="button" BorderBrush="Black" BorderThickness="1" Click="Button_Click" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Padding="0">
			<Button.Background>
				<DrawingBrush TileMode="Tile" ViewportUnits="Absolute" Viewport="0,0,16,16">
					<DrawingBrush.Drawing>
						<DrawingGroup>
							<GeometryDrawing Brush="White">
								<GeometryDrawing.Geometry>
									<RectangleGeometry Rect="0,0,1,1"/>
								</GeometryDrawing.Geometry>
							</GeometryDrawing>
							<GeometryDrawing Brush="LightGray">
								<GeometryDrawing.Geometry>
									<RectangleGeometry Rect="0,0,0.5,0.5"/>
								</GeometryDrawing.Geometry>
							</GeometryDrawing>
							<GeometryDrawing Brush="LightGray">
								<GeometryDrawing.Geometry>
									<RectangleGeometry Rect="0.5,0.5,0.5,0.5"/>
								</GeometryDrawing.Geometry>
							</GeometryDrawing>
						</DrawingGroup>
					</DrawingBrush.Drawing>
				</DrawingBrush>
			</Button.Background>
			<Rectangle>
				<Rectangle.Fill>
					<SolidColorBrush Color="{Binding Color, ElementName=UserControl}"/>
				</Rectangle.Fill>
			</Rectangle>
		</Button>
		<Rectangle Fill="#7F7F7F7F" Visibility="{Binding IsEnabled, ElementName=UserControl, Converter={StaticResource BoolReverseToVisibilityConverter}}"/>
		<Popup x:Name="popup" Placement="Top" StaysOpen="False" AllowsTransparency="{Binding MainWindow.AllowsTransparency, Source={x:Static Application.Current}}">
			<local:ColorPicker Color="{Binding Color, ElementName=UserControl, Mode=TwoWay}" Background="{Binding Background, ElementName=UserControl}" IsAlphaEnabled="{Binding IsAlphaEnabled, ElementName=UserControl, Mode=TwoWay}"/>
		</Popup>
	</Grid>
</UserControl>
